<!--
 * @Description: 查询介绍人信息
 * @Autor: 刘诗文
 * @Date: 2020-12-04 17:28:50
 * @LastEditors: 刘诗文
 * @LastEditTime: 2020-12-07 10:24:42
-->
<template>
  <div>
    <TopFilter :list="topFilterList" :cols="3" :labelWidth="105" @filterChange="changeHandle" @onCollapse="collapseHandle"></TopFilter>
    <FilterTable
      ref="table"
      height="300"
      selectionType="single"
      :columns="columns"
      :datakey="'rows'"
      columnsRef="searchIntroducerInfolsw"
      :onColumnsChange="columns => (this.columns = columns)"
      :onRowSelectChange="onRowSelectChange"
    >
    </FilterTable>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button @click="cancelHandle">取消</el-button>
      <AjaxButton type="primary" :click="saveHandler">保存</AjaxButton>
    </div>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
export default {
  name: 'searchIntroducerInfolsw',
  mixins: [dictionary],
  data() {
    this.selectedData = null;
    this.BaseTable = null;
    return {
      topFilterList: this.createTopFilterList(),
      columns: this.createTableColumns()
    };
  },
  mounted() {
    this.BaseTable = this.$refs.table;
  },
  methods: {
    createTopFilterList() {
      return [
        {
          type: 'INPUT',
          label: '客户姓名',
          fieldName: 'a1',
          initialValue: ''
        },
        {
          type: 'INPUT',
          label: '客户联系方式',
          fieldName: 'a2',
          initialValue: ''
        }
      ];
    },
    createTableColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '车主名称',
          dataIndex: 'a1',
          showOverFlowTip: true
        },
        {
          title: '电话',
          dataIndex: 'a2',
          showOverFlowTip: true
        }
      ];
    },
    changeHandle(val) {
      this.fetchParams = Object.assign({}, val);
    },
    collapseHandle() {
      this.$nextTick(this.BaseTable.EXECUTE_RESET_HEIGHT);
    },
    onRowSelectChange(row) {
      if (!row.length) {
        this.selectedData = null;
      } else {
        this.selectedData = row[0];
      }
    },
    // 保存
    async saveHandler() {},
    // 取消
    cancelHandle() {
      this.$emit('close', false);
    }
  }
};
</script>
<style lang="less" scoped></style>
